import { ref, reactive, computed } from "vue";
import { defineStore } from "pinia";
import { pageHeros } from "@/api/hero";

export const useHeroStore = defineStore("hero", () => {


  const heroPage = reactive({
    pageNum: 1,
    pageSize: 10,
    total: 0,
    datas: [],
  });

  const pageDTO=reactive({
    pageNum: 1,
    pageSize: 10,
    name:""
  })

  const getHeroPage = async () => {
    const res = await pageHeros(pageDTO);
    const data = res.data;
    heroPage.pageNum = parseInt(data.pageNum);
    heroPage.pageSize = parseInt(data.pageSize);
    heroPage.total = parseInt(data.total);
    heroPage.datas = data.datas;
    console.log(heroPage);
  };

  return { heroPage,pageDTO, getHeroPage };
});
